/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Phan1.LietKe.QuayLui;

/**
 *
 * @author Giaotk
 */
public class TapConKphanTu {

    int n, k;
    int[] x = new int[100];
    StringBuilder result = new StringBuilder();

    public TapConKphanTu(int k, int n) {
        this.k = k;
        this.n = n;
        x[0] = 0;
        Process(1);
        System.out.println(result);
    }

    public void Process(int i) {

        for (int j = x[i - 1] + 1; j <= n - k + i; j++) {
            x[i] = j;

            if (i == k) {
                PrintResult();
            } else {
                Process(i + 1);
            }

        }

    }

    public void PrintResult() {
        for (int i = 1; i <= k; i++) {
            result.append(x[i]);
        }
        result.append("\n");
    }
}
